package com.haoran.springboot.controller;

import com.haoran.springboot.webSocket.WiselyMessage;
import com.haoran.springboot.webSocket.WiselyResponse;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;

@Controller
public class WsController {
    @MessageMapping("/welcome")
    @SendTo("/topic/getResponse")//当浏览器发送请求时候会映射这个地址 类似于requestMapping
    public WiselyResponse say(WiselyMessage message) throws Exception{
        Thread.sleep(3000);
        return new WiselyResponse("Welcome,"+message.getName()+"!");
    }
}
